package YesterDay_class;

public class Solution {
    public void siftDown(int parent,int end) {

    }
    //pool的目的是删除一个元素
    public void pool(int parent,int end) {
        //首先 将第一个结点和最后一个结点交换
        int[] elem = new int[10];
        int usedSize = elem.length;

        int tmp = elem[0];
        elem[0] = elem[usedSize - 1];
        elem[usedSize - 1] = tmp;

        siftDown(0,--usedSize);
    }

    //push 插入一个元素
    public void siftUp(int child) {
        int[] elem = new int[10];
        int parent = (child - 1) / 2;
        //已经把元素插入好嘞 开始调整
        while(parent >= 0 && child > 0) {
            if(elem[parent] < elem[child]) {
                int tmp = elem[parent];
                elem[parent] = elem[child];
                elem[child] = tmp;
            } else {
                break;
            }
            child = parent;
            parent = (child - 1) / 2;
        }
    }
}
